package cn.iocoder.yudao.module.mqtt.dal.mysql.configalarm;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.mqtt.dal.dataobject.configalarm.ConfigAlarmDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mqtt.controller.admin.configalarm.vo.*;

/**
 * MQTT报警配置 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ConfigAlarmMapper extends BaseMapperX<ConfigAlarmDO> {

    default PageResult<ConfigAlarmDO> selectPage(ConfigAlarmPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ConfigAlarmDO>()
                .eqIfPresent(ConfigAlarmDO::getAlarmType, reqVO.getAlarmType())
                .eqIfPresent(ConfigAlarmDO::getDataType, reqVO.getDataType())
                .eqIfPresent(ConfigAlarmDO::getGreaterValue, reqVO.getGreaterValue())
                .eqIfPresent(ConfigAlarmDO::getLessValue, reqVO.getLessValue())
                .eqIfPresent(ConfigAlarmDO::getOpenWeixin, reqVO.getOpenWeixin())
                .eqIfPresent(ConfigAlarmDO::getOpenSms, reqVO.getOpenSms())
                .eqIfPresent(ConfigAlarmDO::getArarmStatus, reqVO.getArarmStatus())
                .eqIfPresent(ConfigAlarmDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(ConfigAlarmDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ConfigAlarmDO::getId));
    }


    default List<ConfigAlarmDO> selectList(ConfigAlarmDO reqVO) {
        return selectList(new LambdaQueryWrapperX<ConfigAlarmDO>()
                .eqIfPresent(ConfigAlarmDO::getAlarmType, reqVO.getAlarmType())
                .eqIfPresent(ConfigAlarmDO::getDataType, reqVO.getDataType())
                .eqIfPresent(ConfigAlarmDO::getGreaterValue, reqVO.getGreaterValue())
                .eqIfPresent(ConfigAlarmDO::getLessValue, reqVO.getLessValue())
                .eqIfPresent(ConfigAlarmDO::getOpenWeixin, reqVO.getOpenWeixin())
                .eqIfPresent(ConfigAlarmDO::getOpenSms, reqVO.getOpenSms())
                .eqIfPresent(ConfigAlarmDO::getArarmStatus, reqVO.getArarmStatus())
                .eqIfPresent(ConfigAlarmDO::getDescription, reqVO.getDescription())
                .orderByDesc(ConfigAlarmDO::getId));
    }

}